package com.cuckoo.cuckoo_app2.utils;

import android.content.Context;
import android.content.Intent;

import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import com.cuckoo.cuckoo_app2.model.IntentResponseModel;

public class LocalBroadCodeUtils {

    // 任务刷新
    public static final String LOCAL_BROADCAST_TASK_REFRESH = "com.cuckoo.cuckoo_app2.TASK_REFRESH";

    // 刷新
    public static final String LOCAL_BROADCAST_ACTIVITY_REFRESH = "com.cuckoo.cuckoo_app2.ACTIVITY_REFRESH";

    // 登录失效 重新登录
    public static final String LOCAL_BROADCAST_LOGINOUT_INVALID = "com.cuckoo.cuckoo_app2.LOGINOUT_INVALID";

    // 更新APP
    public static final String LOCAL_BROADCAST_UPDATE_APP = "com.cuckoo.cuckoo_app2.UPDATE_APP";

    /**
     * 公告本地广播发送方法
     *
     * @param context
     * @param action
     * @param responseModel
     */
    public static void sendLocalBroadcast(Context context, String action, IntentResponseModel responseModel) {
        Intent intent = new Intent(action);
        if(responseModel != null){
            intent.putExtra("model", responseModel);
        }
        LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
    }
}
